
import sys
sys.path.append('C:\\Documents and Settings\\miriamf\\My Documents\\Snuppi\\snuppi')


import unittest
import matrix
reload(matrix)
from matrix import Matrix

class MatrixTestCase(unittest.TestCase):

    def setUp(self):
        self.intMatrix = matrix.IntMatrix(5)
        self.intMatrix.setIndex(2,2,9)

        self.rgbMatrix1 = matrix.RgbMatrix(5)
        self.rgbMatrix2 = matrix.RgbMatrix(5)
        self.rgbMatrix1.setIndex(3,3,(1, 2, 3))
        self.rgbMatrix2.setIndex(4,4,(4, 5, 6))
        

    def testRgbMatrixDifference(self):
        rgbMatrix3 = self.rgbMatrix1.getDifferenceMatrix(self.rgbMatrix2)
        assert rgbMatrix3.getIndex(3,3) == (1, 2, 3)
        assert rgbMatrix3.getIndex(4,4) == (-4, -5, -6)


    def testRgbMatrixUnaryFunction(self):
        ls = self.rgbMatrix1.applyUnaryFunction(func)
        assert (ls[18] == 6)

    def testIntMatrixGetSum(self):
        sum = self.intMatrix.getSum()
        assert sum ==  9

def func(x):
    return x[2] * x[1] * x[0]           
        

if __name__ == "__main__":
    unittest.main()
